<?php
   /**
    * Update the user_t based on posted data
    */
   $uid = $_POST['uid'];
   $firstName= $_POST['firstName'];
   $surname= $_POST['surname'];
   $cell_phone = $_POST['cell_phone'];
   //Sanitize the data 
   if (isset($uid)) { // First test passed

   } else {
      die ("No uid set");
   }
   
   echo ("Updating User Table");
   $con = mysqli_connect("mmedia.cput.ac.za", "stud", "stud2pass", "mmt300s");
      if ($con->connect_errno) {
         echo "Failed to connect to MySQL: " . $con->connect_errno;
      } else {
         $tQuery = "UPDATE user_t SET first_name='$firstName', surname='$surname', cell_no='$cell_phone' WHERE uid=$uid";
         $result = $con->query($tQuery);
         echo "For testing purposes only <br/>$tQuery<br/>";
         echo ("You updated ".$con->affected_rows. " Rows");
      }
    $con->close();
?>
